package com.gxa.controller.parking;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.common.utils.Result;
import com.gxa.entity.parking.MonthPay;
import com.gxa.entity.parking.MonthSelect;
import com.gxa.service.parking.MonthPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjl
 * @since 2022-10-11 10:05:39
 */

@Api(tags = "月卡缴费")
@RestController
@RequestMapping("/month-pay")
public class MonthPayController {
    @Autowired
    private MonthPayService monthPayService;

    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("展示月卡缴费")
    @PostMapping("/list")
    public Result selectAll(@RequestBody MonthSelect monthSelect) {
        PageHelper.startPage(monthSelect.getPageNum(),monthSelect.getPageSize());
        List<MonthPay> monthPays = this.monthPayService.selectAll();
        PageInfo<MonthPay> pm = new PageInfo<>(monthPays);

        return Result.success(pm);
    }

    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("按ID查询")
    @GetMapping("/queryById/{id}")
    public Result queryById(@PathVariable("id") Integer id){
        MonthPay monthPays = this.monthPayService.selectById(id);
        return Result.success(monthPays);
    }

    @CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
    @ApiOperation("按条件查询")
    @PostMapping("/queryByCondition")
    public Result selectByCondition(@RequestBody MonthSelect monthSelect){
        PageHelper.startPage(monthSelect.getPageNum(),monthSelect.getPageSize());
        List<MonthPay> monthPays = this.monthPayService.selectByCondition(monthSelect);
        PageInfo<MonthPay> pm = new PageInfo<>(monthPays);
        return Result.success(pm);
    }
}
